{extend name="public/header" /}

{block name="title"}{//:curPurviewName()}{/block}
{block name="js"}
<script type="text/javascript" src="/static/admin/js/xadmin.js"></script>
{/block}
{block name="body"}
<body>
<div class="x-nav">
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:left" onclick="location.reload()" title="刷新">
        <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
    </a>
</div>
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form">

            <div class="layui-form-item">
                <label for="username" class="layui-form-label">
                    <span class="x-red">*</span>用户名
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="username" name="username" value="{$arrData.username}" required  lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label for="password" class="layui-form-label">
                    <span class="x-red">*</span>密码
                </label>
                <div class="layui-input-inline">
                    <input type="password" id="password" name="password" placeholder="默认不变" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label for="re_password" class="layui-form-label">
                    <span class="x-red">*</span>重复密码
                </label>
                <div class="layui-input-inline">
                    <input type="password" id="re_password" name="re_password" placeholder="默认不变" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label for="role_id" class="layui-form-label">
                    <span class="x-red">*</span>角色
                </label>
                <div class="layui-input-inline">
                    <select id="role_id" name="role_id" required lay-verify="required" lay-search>
                        <option value="">选择角色</option>
                        {foreach $arrRole as $key=>$vo }
                        <option value="{$vo['id']}" {if $vo.id == $arrData.role_id} selected {/if}>{$vo['name']}</option>
                        {/foreach}
                    </select>
                </div>
            </div>

            <div class="layui-form-item">
                <label for="real_name" class="layui-form-label">
                    <span class="x-red">*</span>真实姓名
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="real_name" name="real_name" value="{$arrData.real_name}" required  lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label for="mobile" class="layui-form-label">
                    <span class="x-red">*</span>手机号码
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="mobile" name="mobile" value="{$arrData.mobile}" required lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <input type="hidden" name="id" value="{$arrData.id}">
                <label class="layui-form-label"></label>
                <button class="layui-btn" lay-filter="add" lay-submit="">
                    修改
                </button>
            </div>
        </form>
    </div>
</div>
</body>
<script>
    layui.use(['form', 'layer'], function () {
        var form = layui.form
        var layer = layui.layer
        //监听提交
        form.on('submit(add)', function (obj) {
            $.ajax({
                type: "post",
                url: obj.form.action,
                data: obj.field,
                dataType: "json",
                success: function (res) {
                    if (res.code == 0) {
                        layer.msg(res.msg, {
                            icon: 1,
                            time: 1000 //2秒关闭（如果不配置，默认是3秒）
                        }, function () {
                            parent.location.reload();
                        });
                    } else {
                        layer.msg(res.msg, {
                            icon: 2,
                            time: 2000//2秒关闭（如果不配置，默认是3秒）
                        });
                    }
                }
            });
            return false;
        });
    });
</script>
{/block}
</html>
